//全局变量   
var currentId; //存放当前编辑行ID，擦除模态框信息

//控制分机ip
var CTRL_NODE_IP = []
//存储分机ip
var STORAGE_NODE_IP = []

//普罗米修斯提供
var IPS = {
	"controlIps": "",
	"storageIps": ""
}
var nodeTypeCTRL = {
	"nodeType": "CTRL_NODE"
}
var nodeTypeSTORAGE = {
	"nodeType": "STORAGE_NODE"
}
var nodeTypeCTRLWeb = JSON.stringify(nodeTypeCTRL)
var nodeTypeSTORAGEWeb = JSON.stringify(nodeTypeSTORAGE)

$.ajax({
	url: 'http://' + ipm + ':8081/node/queryNodes',
	type: 'POST',
	contentType: 'application/json',
	dataType: 'json',
	data: nodeTypeCTRLWeb,
	success: function (response) {
		// console.log(response);
		for (var i = 0; i < response.data.length; i++) {
			CTRL_NODE_IP.push(response.data[i].ip)
		}
		// console.log(CTRL_NODE_IP);
	}
});
$.ajax({
	url: 'http://' + ipm + ':8081/node/queryNodes',
	type: 'POST',
	contentType: 'application/json',
	dataType: 'json',
	data: nodeTypeSTORAGEWeb,
	success: function (response) {
		// console.log(response);
		for (var i = 0; i < response.data.length; i++) {
			STORAGE_NODE_IP.push(response.data[i].ip)
		}
		// console.log(STORAGE_NODE_IP);
		for (var i = 0; i < 10; i++) {
			if (STORAGE_NODE_IP) {
				layui.use(['form', 'upload', 'layer'], function () {
					var form = layui.form;
					//使用循环遍历，给下拉列表赋值
					$.each(STORAGE_NODE_IP, function (index, value) {
						$('#storage_ip').append(new Option(value, value));// 下拉菜单里添加元素
					});
					console.log(STORAGE_NODE_IP);
					form.render("select");
				});
				break;
			} else {
				alert('加载失败，请刷新重试')
			}
		}
	}
});
IPS.controlIps = CTRL_NODE_IP
IPS.storageIps = STORAGE_NODE_IP

//保存配置请求
function postQuestSave(args) {
	var xhr = new XMLHttpRequest();
	// 配置请求
	xhr.open('POST', 'http://' + ipm + ':8081/dict/save', true);
	xhr.setRequestHeader('content-Type', 'application/json');
	// 发送 JSON 数据
	xhr.send(JSON.stringify(args));
	// 监听请求的状态
	xhr.onreadystatechange = function () {
		console.log(xhr.readyState);
		if (xhr.readyState === 4 && xhr.status === 200) {
			console.log(xhr.responseText);
		}
	};
}


//读取配置请求
function postQuestRead() {
	$.ajax({
		url: 'http://' + ipm + ':8081/dict/query',
		type: 'POST',
		contentType: 'application/json',
		dataType: 'json',
		data: {},
		success: function (response) {
			console.log(response);
		}
	});
}


//字典查询JSON拼接
function dictRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 1) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			dict_request = testa;
			console.log(testa);
			testb = testa.dict;
			for (j; j < testb.length; j++) {
				var tableA = {
					"name": "",
					"inserttime": "",
					"updatetime": "",
					"ID": ""
				};
				editmodel.push(testb[j].context);
				tableA.name = testb[j].name;
				tableA.inserttime = dm8content[i].inserttime;
				tableA.updatetime = dm8content[i].updatetime;
				tableA.ID = k++;
				tablelist.push(tableA);
			}
		}
		createTab();
	}
}
//协议字段解析表查询JSON拼接
function protolistRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 2) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			parselist_request = testa;
			testb = testa.parse_list;
			for (j; j < testb.length; j++) {
				var tableA = {
					"name": "",
					"inserttime": "",
					"updatetime": "",
					"ID": ""
				};
				editmodel.push(testb[j].context);
				tableA.name = testb[j].name;
				tableA.inserttime = dm8content[i].inserttime;
				tableA.updatetime = dm8content[i].updatetime;
				tableA.ID = k++;
				tablelist.push(tableA);
			}
		}
		createTab();
	}
}
//协议字段查询JSON拼接
function protofieldRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 3) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			proto_field_request = testa;
			testb = testa.protocol_segments;
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"name": "",
					"value_type": "",
					"value_length": "",
					"method": "",
					"value": "",
					"unit": "",
					"dbfield": "",
					"ID": ""
				};
				tableA.id = testb[j].id;
				tableA.name = testb[j].name;
				tableA.value_type = testb[j].value_type;
				tableA.value_length = testb[j].value_length;
				if (testb[j].dict_name == "") {
					tableA.method = "字典";
					tableA.value = "null"
				} else if (testb[j].dict_name) {
					tableA.method = "字典";
					tableA.value = testb[j].dict_name;
				}
				else if (testb[j].logical_expressions) {
					tableA.method = "逻辑表达式";
					tableA.value = testb[j].logical_expressions;
				}
				else if (testb[j].parse_list_name == "") {
					tableA.method = "解析表";
					tableA.value = "null";
				}
				else if (testb[j].parse_list_name) {
					tableA.method = "解析表";
					tableA.value = testb[j].parse_list_name;
				}
				else if (testb[j].string == "hex") {
					tableA.method = "原始值";
					tableA.value = testb[j].string;
				}
				else if (testb[j].string == "ascii") {
					tableA.method = "字符串";
					tableA.value = testb[j].string;
				}
				else if (testb[j].strtrim) {
					tableA.method = "分隔符";
					tableA.value = testb[j].strtrim;
				}
				else if (testb[j].bits) {
					tableA.method = "位处理";
					tableA.value = "bits";
				}
				tableA.unit = testb[j].unit;
				tableA.dbfield = testb[j].dbfield;
				tableA.ID = k++;
				tablelist.push(tableA);
			}
		}
		//createTab();
	}
}
//协议查询JSON拼接
function protoRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 4) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			proto_request = testa;
			console.log(testa);
			testb = testa.protocols;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"name": "",
					"segment_list": "",
					"segment_list_num": "",
					"segment_tag": "",
					"ID": ""
				}
				editmodel.push(testb[j].segment_tag);
				tableA.name = testb[j].name;
				tableA.segment_list = testb[j].segment_list;
				var segment_list = testb[j].segment_list;
				tableA.segment_list_num = segment_list.length;
				tableA.segment_tag = testb[j].segment_tag.length;
				tableA.ID = k++;
				tablelist.push(tableA);
			}
		}
		createTab();
	}
}
//协议数据规则查询JSON拼接
function ruleRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 5) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			rule_request = testa;
			console.log(testa);
			testb = testa.proto_rules;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"rule_name": "",
					"dstip": "",
					"dst_port": "",
					"proto_name": "",
					"segment_tag": [
						{ "id": 22, "tag": 40960 }, // id为协议字段对应的id
						{ "id": 34, "tag": 45855 }
					],
					"sgmt_tbls": [1, 2, 3, 5], //segment table id
					"proc_method": "",
					// "expired": "",
					"expired_val": "",
					"expired_unit": "",
					"level": "",
					"enabled": "",
					"button": "",
					"storage_rule": "", //选择storage_rules.json中的配置，并完成绑定
					"ID": ""
				}
				tag_editmodel.push(testb[j].segment_tag);
				tableA.id = testb[j].id;
				tableA.rule_name = testb[j].rule_name;
				tableA.dstip = testb[j].dstip;
				tableA.dst_port = testb[j].dst_port;
				tableA.proto_name = testb[j].proto_name;
				tableA.sgmt_tbls = testb[j].sgmt_tbls;
				tableA.proc_method = testb[j].proc_method;
				tableA.expired_val = testb[j].expired.val;
				// if (testb[j].expired.unit == "day") {
				// 	tableA.expired_unit = "天";
				// } else if (testb[j].expired.unit == "min") {
				// 	tableA.expired_unit = "分钟";
				// } else if (testb[j].expired.unit == "hour") {
				// 	tableA.expired_unit = "小时";
				// }
				if (testb[j].expired.unit == "day") {
					tableA.expired_unit = "day";
				} else if (testb[j].expired.unit == "min") {
					tableA.expired_unit = "min";
				} else if (testb[j].expired.unit == "hour") {
					tableA.expired_unit = "hour";
				} else if (testb[j].expired.unit == "year") {
					tableA.expired_unit = "year";
				} else if (testb[j].expired.unit == "month") {
					tableA.expired_unit = "month";
				}else if (testb[j].expired.unit == "FV") {
					tableA.expired_unit = "FV";
				}
				// tableA.expired = testb[j].expired;
				tableA.level = testb[j].level;
				// tableA.enabled = testb[j].enabled;
				tableA.enabled = testb[j].button;

				tableA.storage_rule = testb[j].storage_rule.id + "," + testb[j].storage_rule.name;
				tableA.ID = k++;
				tablelist.push(tableA);
			}
		}
		// createTab();
	}
}
//文件类型JSON拼接
function filetypeRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 6) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			file_type_request = testa;
			testb = file_type_request.type_defines
			for (j; j < testb.length; j++) {
				var tableA = {
					"type_defines": "",
					"filetype_intro": ""
				}
				tableA.type_defines = testb[j]
				tablelist.push(tableA);

			}
		}
		createTab();
	}
}
//大数据规则查询JSON拼接
function bruleRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 7) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			data_rule_request = testa;
			console.log(testa);
			testb = testa.rules_cfg;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"srcip": "",
					"dstip": "",
					"src_port": "",
					"dst_port": "",
					"proto": "",
					"storage_rule": "",
					"enabled": "",
					"button": "",
					"ID": ""
				}
				tableA.id = testb[j].id;
				tableA.srcip = testb[j].srcip;
				tableA.dstip = testb[j].dstip;
				tableA.src_port = testb[j].src_port;
				tableA.dst_port = testb[j].dst_port;
				tableA.proto = testb[j].proto;
				tableA.storage_rule = testb[j].storage_rule.id + "," + testb[j].storage_rule.name;
				// tableA.enabled = testb[j].enabled;
				tableA.enabled = testb[j].button;
				tableA.ID = k++;
				tablelist.push(tableA);

			}
		}
	}
}

//远端控制的回放配置JSON拼接
function playbackConfigRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 8) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			playback_config_request = testa;
			console.log(testa);
			testb = testa.remote;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": 1,
					"sensor_id": 0,
					"data_id": 1,
					"data_type": "点迹x",
					"space": "空间1",
					"data_path": "/dj-x",
				}
				tableA.id = testb[j].id;
				tableA.sensor_id = testb[j].sensor_id;
				tableA.data_id = testb[j].data_id;
				if (testb[j].is_protocol == true) {
					tableA.data_type = "协议-" + testb[j].data_type;
				} else {
					tableA.data_type = testb[j].data_type;
				}
				tableA.space = testb[j].space;
				tableA.data_path = testb[j].data_path;
				tablelist.push(tableA);

			}
		}
	}
}

//本地的回放配置JSON拼接
function localplaybackConfigRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 8) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			playback_config_request = testa;
			console.log(testa);
			testb = testa.local;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"data_type": "",
					"space": "",
					"data_path": "",
					"dest_ip": "",
					"dest_port": "",
				}
				tableA.id = testb[j].id;
				tableA.sensor_id = testb[j].sensor_id;
				tableA.data_id = testb[j].data_id;
				if (testb[j].is_protocol == true) {
					tableA.data_type = "协议-" + testb[j].data_type;
				} else {
					tableA.data_type = testb[j].data_type;
				}
				tableA.space = testb[j].space;
				tableA.data_path = testb[j].data_path;
				tableA.dest_ip = testb[j].dest_ip;
				tableA.dest_port = testb[j].dest_port;
				tablelist.push(tableA);

			}
		}
	}
}


//数据库表配置JSON拼接
function DBtableConfigRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 9) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			DBtable_config_request = testa;
			console.log(testa);
			testb = testa.tables;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": 1,
					"tlbname": "dsaf",
					"segments": [1, 2, 3, 4],
					// "maxsize": { "val": 2, "unit": "TB" },
					"maxsize_val": "",
					"maxsize_unit": "",
					"comment": "",
				}
				tableA.id = testb[j].id;
				tableA.tlbname = testb[j].tlbname;
				tableA.segments = testb[j].segments;
				tableA.maxsize_val = testb[j].maxsize.val;
				tableA.maxsize_unit = testb[j].maxsize.unit;
				tableA.comment = testb[j].comment;
				tablelist.push(tableA);

			}
		}
	}
}

//文件存储规则配置JSON拼接
function storageRulesConfigRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 10) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			storage_rules_config_request = testa;
			console.log(testa);
			testb = testa.rules_cfg;
			console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": 1,
					"name": "",
					"dump_method_method": "",
					"dump_method_cfg": "",
					"dump_path1": "",
					"dump_path2": "",
					"dump_path3": "",
					"auto_backups1": "",
					"auto_backups2": "",
					"auto_backups3": "",
					"expired_val": "",
					"expired_unit": "",
					"storage_capacity_val": "",
					"storage_capacity_unit": "",
					"level": 5,
					"file_prefix": "dat" //默认dat
				}
				tableA.id = testb[j].id;
				tableA.name = testb[j].name;
				if (testb[j].dump_method.method == "expired") {
					tableA.dump_method_method = "时长(分钟)";
				} else if (testb[j].dump_method.method == "size") {
					tableA.dump_method_method = "大小(GB)";
				}
				tableA.dump_method_cfg = testb[j].dump_method.cfg;
				tableA.dump_path1 = testb[j].dump_path[0];
				tableA.dump_path2 = testb[j].dump_path[1];
				tableA.dump_path3 = testb[j].dump_path[2];
				tableA.auto_backups1 = testb[j].auto_backups[0];
				tableA.auto_backups2 = testb[j].auto_backups[1];
				tableA.auto_backups3 = testb[j].auto_backups[2];
				tableA.expired_val = testb[j].expired.val;
				if (testb[j].expired.unit == "day") {
					tableA.expired_unit = "day";
				} else if (testb[j].expired.unit == "min") {
					tableA.expired_unit = "min";
				} else if (testb[j].expired.unit == "hour") {
					tableA.expired_unit = "hour";
				} else if (testb[j].expired.unit == "year") {
					tableA.expired_unit = "year";
				} else if (testb[j].expired.unit == "month") {
					tableA.expired_unit = "month";
				}else if (testb[j].expired.unit == "FV") {
					tableA.expired_val = "永久"
					tableA.expired_unit = "FV";
				}
				tableA.storage_capacity_val = testb[j].storage_capacity.val;
				tableA.storage_capacity_unit = testb[j].storage_capacity.unit;
				tableA.level = testb[j].level;
				tableA.file_prefix = testb[j].file_prefix;
				tablelist.push(tableA);
			}
		}
	}
}

//开放接口配置JSON拼接
function openApiConfigRead(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 11) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			open_api_request = testa;
			console.log(open_api_request);
			testb = testa.api_cfg;
			// console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": 0,
					"expired": {
						"val": 2,
						"unit": "day"
					},
					"database_tables": [],
					"files_path_id": [],
					"key": "",
					"deadline": "yyyy/mm/dd HH:mm",
					"enabled": true,
					"comment": ""
				}
				tableA.id = testb[j].id;
				tableA.database_tables = testb[j].access_type[0].database_tables;
				tableA.files_path_id = testb[j].access_type[1].files_path_id;
				tableA.key = testb[j].key;
				tableA.deadline = testb[j].deadline;
				tableA.enabled = testb[j].enabled;
				tableA.comment = testb[j].comment;
			
				api_tablelist.push(tableA);
			}
		}
	}
}

//创建协议字段列表OBJ
function createProtofieldobj(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 3) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			proto_field_request = testa;
			testb = testa.protocol_segments;
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"name": "",
					"dbfield": "",
					"value_type": "",
					"value_length": "",
					"method": "",
					"value": "",
					"ID": ""
				};
				tableA.id = testb[j].id;
				tableA.name = testb[j].name;
				tableA.dbfield = testb[j].dbfield;
				tableA.value_type = testb[j].value_type;
				tableA.value_length = testb[j].value_length;
				if (testb[j].dict_name) {
					tableA.method = "dict_name";
					tableA.value = testb[j].dict_name;
				}
				else if (testb[j].logical_expressions) {
					tableA.method = "logical_expressions";
					tableA.value = testb[j].logical_expressions;
				}
				else if (testb[j].parse_list_name) {
					tableA.method = "parse_list_name";
					tableA.value = testb[j].parse_list_name;
				}
				else if (testb[j].string) {
					tableA.method = "string";
					tableA.value = testb[j].string;
				}
				else if (testb[j].strtrim) {
					tableA.method = "strtrim";
					tableA.value = testb[j].strtrim;
				}
				else if (testb[j].bits) {
					tableA.method = "bits";
					tableA.value = "bits";
				}
				tableA.ID = k++;
				protofeild.push(tableA);
			}
		}
	}
}

//创建协议列表OBJ
function createProtoObj(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 4) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			proto_request = testa;
			//console.log(testa);
			testb = testa.protocols;
			//console.log(testb);
			for (j; j < testb.length; j++) {
				var tableA = {
					"name": "",
					"segment_list": "",
					"segment_list_num": "",
					"segment_tag": "",
					"segment_tag_obj": "",
					"ID": ""
				}
				editmodel.push(testb[j].segment_tag);
				tableA.name = testb[j].name;
				tableA.segment_list = testb[j].segment_list;
				var segment_list = testb[j].segment_list;
				tableA.segment_list_num = segment_list.length;
				tableA.segment_tag = testb[j].segment_tag.length;
				tableA.segment_tag_obj = testb[j].segment_tag;
				tableA.ID = k++;
				protolist.push(tableA);
			}
		}
	}
}

//创建文件存储规则OBJ
function createStorageRulesObj(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 10) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			testb = testa.rules_cfg;
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"name": "",
				}
				tableA.id = testb[j].id;
				tableA.name = testb[j].name;
				tableA.expired = testb[j].expired;
				tableA.level = testb[j].level;
				storage_rule_select.push(tableA);
			}
		}
	}
}

//创建数据库表配置OBJ
function createDatabaseTblObj(args) {
	var dm8data = args.data;
	var dm8content = dm8data.content;
	var datalist = [];
	var testa;
	var testb;
	var i = 0;
	var j = 0;
	var k = 1;
	for (i; i < dm8content.length; i++) {
		if (dm8content[i].cfgType == 9) {
			datalist[i] = dm8content[i].content;
			testa = JSON.parse(datalist[i]);
			testb = testa.tables;
			for (j; j < testb.length; j++) {
				var tableA = {
					"id": "",
					"tlbname": "",
					"ID": ""
				}
				tableA.id = testb[j].id;
				tableA.tlbname = testb[j].tlbname;
				tableA.ID = k++;
				database_tbl_obj.push(tableA);
			}
		}
	}
}

{/* <style>                 
.login-user {
    display: flex;
    color: #000;
    line-height: 30px;
}
.login-user input{
    height: 46px;
    border-radius: 4px;
    margin: 0px 4px;
}
</style>
 
<div class="layui-form-item login-user">
    <input type="text" id="ip_b_1" class="layui-input numInput" />.
    <input type="text" id="ip_b_2" class="layui-input numInput" />.
    <input type="text" id="ip_b_3" class="layui-input numInput" />.
    <input type="text" id="ip_b_4" class="layui-input numInput" />
</div> */}


// ip输入框的最大值
let ip_max = 255;
let port_max = 65535;
let year_max = 10;
let month_max = 12;
let day_max = 30;

let port_min = 1;
let FileIPL = localStorage.getItem("showIP") || "255.255.255.0";
setIpInput(FileIPL);

//设置IP端口默认值
function setIpInput(ip) {
	let newIp = ip.split('.');
	$("#ip1").val(newIp[3]);
	$("#ip2").val(newIp[3]);
	$("#ip3").val(newIp[3]);
	$("#ip4").val(newIp[3]);
	$("#src_mask1").val(newIp[0]);
	$("#src_mask2").val(newIp[1]);
	$("#src_mask3").val(newIp[2]);
	$("#src_mask4").val(newIp[3]);
	$("#dst_mask1").val(newIp[0]);
	$("#dst_mask2").val(newIp[1]);
	$("#dst_mask3").val(newIp[2]);
	$("#dst_mask4").val(newIp[3]);
}


// 监听键盘输入事件
$(".numInput").bind("keydown", function (event) {
	let code = event.keyCode;
	// 只能输入数字键、删除键、小数点，tab键，其他的都不能输入
	if ((code < 48 && 8 != code && 37 != code && 39 != code && 9 != code) ||
		(code > 57 && code < 96) ||
		(code > 105 && 110 != code && 190 != code)) {
		return false;
	}
	// 如果输入了点，右键 (.)，则直接跳转到下一个输入框并选中值
	if (code == 110 || code == 190 || code == 39 || code == 40) {
		$(this).next().focus()
			.select();
		return false;
	}
	if (code == 37 || code == 38) {
		$(this).prev().focus()
			.select();
		return false;
	}
});
// 监听键盘离开事件
$(".numInput").bind("keyup", function (event) {
	// 判断当前输入框的值
	let code = event.keyCode;
	let value = $(this).val();

	// 如果输入的值大于ip最大值，则默认设置为255
	if (value != null && value != '' && parseInt(value) > ip_max) {
		$(this).val("255");
		return false;
	}
	// 如果输入框的值大于100并且按键不为上下左右点，并且符合规则，则跳转到下一个输入框并选中值
	if ((code !== 9 && code !== 110 && code !== 190 && code !== 39 && code !== 37 && code !== 38 && code !== 40) && value != null && value != '' && parseInt(value) >= 100 && parseInt(value) <= ip_max) {
		$(this).next().focus()
			.select();
		return false;
	}
	// 判断是否是0开头的不规范数字
	if (value != null && value != '' && parseInt(value) != 0) {
		// 如果当前输入的是0开头，则把0去掉,方法是直接转数字即可
		value = parseInt(value);
		if (isNaN(value)) {
			$(this).val("");
		} else {
			$(this).val("" + value);
		}
	}
});

// 失去焦点事件
$(".numInput").bind("blur", function () {
	let value = $(this).val();
	// 如果失去焦点，当前的值为0，则加上红色边框，否则去掉红色边框
	if (value == null || value == '' || value == undefined) {
		$(this).css("border-color", "red");
	} else {
		$(this).css("border-color", "");
	}
});








// 监听键盘输入事件
$(".port").bind("keydown", function (event) {
	let code = event.keyCode;
	// 只能输入数字键、删除键、小数点，tab键，其他的都不能输入
	if (code >= 48 && code <= 57 && code >= 96 && code <= 105) {
		return false;
	} else if (code === 8) {

	}
});

// 监听键盘离开事件
$(".port").bind("keyup", function (event) {
	// 判断当前输入框的值
	let code = event.keyCode;
	let value = $(this).val();

	// 如果输入的值大于ip最大值，则默认设置为65535
	if (value != null && value != '' && parseInt(value) > port_max) {
		$(this).val("65535");
		return false;
	}

	// 判断是否是0开头的不规范数字
	if (value != null && value != '' && parseInt(value) != 0) {
		// 如果当前输入的是0开头，则把0去掉,方法是直接转数字即可
		value = parseInt(value);
		if (isNaN(value)) {
			$(this).val("");
		} else {
			$(this).val("" + value);
		}
	}
});


// 失去焦点事件
$(".port").bind("blur", function () {
	let value = $(this).val();
	// 如果失去焦点，当前的值为0，则加上红色边框，否则去掉红色边框
	if (value == null || value == '' || value == undefined) {
		$(this).css("border-color", "red");
	} else {
		$(this).css("border-color", "");
	}
});





// 监听键盘离开事件
$(".expired").bind("keyup", function (event) {
	// 判断当前输入框的值
	let code = event.keyCode;
	let value = $(this).val();

	// 如果输入的值大于ip最大值，则默认设置为65535
	if (value != null && value != '' && parseInt(value) > year_max) {
		$(this).val("10");
		return false;
	}

	// 判断是否是0开头的不规范数字
	if (value != null && value != '' && parseInt(value) != 0) {
		// 如果当前输入的是0开头，则把0去掉,方法是直接转数字即可
		value = parseInt(value);
		if (isNaN(value)) {
			$(this).val("");
		} else {
			$(this).val("" + value);
		}
	}
});

// 监听键盘离开事件
$(".expired1").bind("keyup", function (event) {
	// 判断当前输入框的值
	let code = event.keyCode;
	let value = $(this).val();

	// 如果输入的值大于ip最大值，则默认设置为65535
	if (value != null && value != '' && parseInt(value) > month_max) {
		$(this).val("12");
		return false;
	}

	// 判断是否是0开头的不规范数字
	if (value != null && value != '' && parseInt(value) != 0) {
		// 如果当前输入的是0开头，则把0去掉,方法是直接转数字即可
		value = parseInt(value);
		if (isNaN(value)) {
			$(this).val("");
		} else {
			$(this).val("" + value);
		}
	}
});

// 监听键盘离开事件
$(".expired2").bind("keyup", function (event) {
	// 判断当前输入框的值
	let code = event.keyCode;
	let value = $(this).val();

	// 如果输入的值大于ip最大值，则默认设置为65535
	if (value != null && value != '' && parseInt(value) > day_max) {
		$(this).val("30");
		return false;
	}

	// 判断是否是0开头的不规范数字
	if (value != null && value != '' && parseInt(value) != 0) {
		// 如果当前输入的是0开头，则把0去掉,方法是直接转数字即可
		value = parseInt(value);
		if (isNaN(value)) {
			$(this).val("");
		} else {
			$(this).val("" + value);
		}
	}
});


//大数据选择框
$(document).ready(function () {
	$('#storage_select').bind('change', function () {
		var res = $(this).val();
		if (res == 1) {
			$('#storage_one').show();
			$('#storage_two').hide();
			$('#storage_three').hide();
		} else if (res == 2) {
			$('#storage_one').hide();
			$('#storage_two').show();
			$('#storage_three').hide();
		} else if (res == 3) {
			$('#storage_one').hide();
			$('#storage_two').hide();
			$('#storage_three').show();
		}
	});
});


function editable_cn() {
	return {
		type: 'text',
		title: '输入新的内容',
		emptytext: '未定义'
	}
}

///限制输入数字||||onkeypress="return (/[\d\.]/.test(String.fromCharCode(event.keyCode)))"